package com.znyj.servlet.model;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.sql.Timestamp;

/**
 * Created by gaoliwei02 on 17/6/26.
 */
public class ReportQueryModel {
    private String group = "";
    private String order = "DESC";
    private int limit = 0;
    private int offset = 0;
    private int pageSize = 15;
    private int pageNumber = 0;

    private String deviceId;
    private String statusA;
    private String statusB;
    private String onlineStatus;
    private String mVersion;
    private Timestamp startTime;
    private Timestamp endTime;


    public ReportQueryModel(String receiveData) {
        JSONObject receive = JSON.parseObject(receiveData);

        order = receive.getString("order");
        limit = receive.getInteger("limit");
        offset = receive.getInteger("offset");
        try {
            pageSize = Integer.parseInt(receive.getString("pageSize"));
        } catch (Exception e) {
            pageSize = -1;
        }
        try {
            pageNumber = receive.getInteger("pageNumber");
        } catch (Exception e) {
            pageNumber = offset / pageSize + 1;
        }


        deviceId = receive.getString("deviceId");
        statusA = receive.getString("statusA");
        statusB = receive.getString("statusB");
        onlineStatus = receive.getString("onlineStatus");
        mVersion = receive.getString("mVersion");

        try {
            startTime = Timestamp.valueOf(receive.getString("startTime"));
            endTime = Timestamp.valueOf(receive.getString("endTime"));
        } catch (Exception e) {

        }
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getStatusB() {
        return statusB;
    }

    public void setStatusB(String statusB) {
        this.statusB = statusB;
    }

    public String getStatusA() {
        return statusA;
    }

    public void setStatusA(String statusA) {
        this.statusA = statusA;
    }


    public String getOnlineStatus() {
        return onlineStatus;
    }

    public void setOnlineStatus(String onlineStatus) {
        this.onlineStatus = onlineStatus;
    }

    public String getmVersion() {
        return mVersion;
    }

    public void setmVersion(String mVersion) {
        this.mVersion = mVersion;
    }

    public Timestamp getStartTime() {
        return startTime;
    }

    public void setStartTime(Timestamp startTime) {
        this.startTime = startTime;
    }

    public Timestamp getEndTime() {
        return endTime;
    }

    public void setEndTime(Timestamp endTime) {
        this.endTime = endTime;
    }

    public int getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(int pageNumber) {
        this.pageNumber = pageNumber;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public String getGroup() {
        return group;
    }

    public void setGroup(String group) {
        this.group = group;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }
}
